package com.erp.entity.sale;

import com.erp.entity.goods.MultipleUnit;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public class SaleDetail {
    private Integer id;

    private String linkSaleNumber;
    private String linkSaleOrderNumber;
    private String linkSaleRejectedNumber;
    private String linkLogisticsNumber;

    private Integer goodsId;
    private Integer basicUnitId;
    private Integer multipleUnitId;

    private Integer goodsNum;

    private Integer unshipped;



    private Integer sellwareHouse;

    private Integer basicNum;

    private BigDecimal salePrice;

    private Integer isGift;

    private BigDecimal taxRate;

    private BigDecimal salePriceTax;

    private BigDecimal taxPrice;
    private BigDecimal salePriceTaxDis;

    private BigDecimal goodsDiscountRate;

    private BigDecimal goodsDiscountNum;

    private BigDecimal goodsSalePriceDis;

    private BigDecimal goodsTotalPriceDis;

    private BigDecimal goodsPriceAndTax;

    private String sourceOrderNum;

    private BigDecimal refCost;

    private BigDecimal actualCost;

    private BigDecimal eGrossProfit;

    private BigDecimal eGrossProfitPc;

    private BigDecimal recentCost;

    private String origin;

    private String registerNumber;

    private String productionLicense;

    private Integer companyId;

    private String goodsRemarks;

    private Integer isReturn;//是否退货(0未退货 1部分退货 2全部退货)
    private Integer returnNum;//退货数量


//  -----------冗余字段---------------------

    private String goodsName;//商品名称
    private String goodsImage;//商品图片
    private String goodsAttribute;//商品属性
    private String goodsBrand;//商品品牌

    private String basicUnitName;//基本单位名称
    private Integer sourceOrderId;//关联的源销货订单的id
    private String multipleUnitName;//多单位名称
    private String sellwareHouseName;//出库仓库名称
    private List<MultipleUnit> multipleUnitList;
    public SaleDetail(){}

    public SaleDetail(BigDecimal salePrice){//用来生产销货订单的构造方法，初始化数据
        //设置商品数量初始参数
        setBasicNum(1);
        setGoodsNum(1);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价
        //设置价税合计
        setGoodsPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计
        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountNum(BigDecimal.ZERO);//折扣额
        setGoodsSalePriceDis(salePrice);//折后单价
        //设置商品的折后金额
        setGoodsTotalPriceDis(getGoodsSalePriceDis().multiply(BigDecimal.valueOf(getBasicNum())));
    }
    public SaleDetail(BigDecimal salePrice,BigDecimal taxRate,
                           BigDecimal discountRate,Integer goodsNum,
                           Integer basicNum){
        setGoodsNum(goodsNum);
        setBasicNum(basicNum);
        setSalePrice(salePrice);


        //设置税率相关信息
        setTaxRate(taxRate);
        setTaxPrice(BigDecimal.valueOf(getBasicNum()).multiply(salePrice).multiply(getTaxRate().multiply(BigDecimal.valueOf(0.01))));//计算税额
        setSalePriceTax(salePrice.add(salePrice.multiply(taxRate.multiply(BigDecimal.valueOf(0.01)))));//设置含税单价

        //设置折扣相关信息
        setGoodsDiscountRate(discountRate);//设置商品折扣率

        setGoodsDiscountNum(BigDecimal.valueOf(basicNum)
                .multiply(discountRate.multiply(BigDecimal.valueOf(0.01)))
                .multiply(salePrice));//设置商品折扣额
        setGoodsSalePriceDis(discountRate.multiply(salePrice).multiply(BigDecimal. valueOf(0.01)).add(salePrice)); //设置商品折后单价
        setGoodsTotalPriceDis(getGoodsSalePriceDis().multiply(BigDecimal.valueOf(getBasicNum())));//设置商品折后金额
        setSalePriceTaxDis(getGoodsSalePriceDis().add(salePrice.multiply(getTaxRate().multiply(BigDecimal.valueOf(0.01)))));//设置商品折后含税单价
        //设置商品价税合计
        setGoodsPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(basicNum)));
    }
    public void setBasicInfo(BigDecimal salePrice){
        //设置商品数量初始参数
        setBasicNum(1);
        setGoodsNum(1);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价
        //设置价税合计
        setGoodsPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计
        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountNum(BigDecimal.ZERO);//折扣额
        setGoodsSalePriceDis(salePrice);//折后单价
        //设置商品的折后金额
        setGoodsTotalPriceDis(getGoodsSalePriceDis().multiply(BigDecimal.valueOf(getBasicNum())));
    }
    public void setBasicInfo(BigDecimal salePrice,Integer goodsNum,Integer basicNum){
        //设置商品数量初始参数
        setBasicNum(basicNum);
        setGoodsNum(goodsNum);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价
        //设置价税合计
        setGoodsPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计
        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountNum(BigDecimal.ZERO);//折扣额
        setGoodsSalePriceDis(salePrice);//折后单价
        //设置商品的折后金额
        setGoodsTotalPriceDis(getGoodsSalePriceDis().multiply(BigDecimal.valueOf(getBasicNum())));
    }
    public void setBasicInfo(String linkSaleNumber,Integer companyId,Integer unshipped,
                             Integer isReturn,Integer returnNum){
        setLinkSaleNumber(linkSaleNumber);
        setCompanyId(companyId);
        setUnshipped(unshipped);
        setIsReturn(isReturn);
        setReturnNum(returnNum);
    }

    public String getLinkSaleOrderNumber() {
        return linkSaleOrderNumber;
    }

    public void setLinkSaleOrderNumber(String linkSaleOrderNumber) {
        this.linkSaleOrderNumber = linkSaleOrderNumber;
    }

    public String getLinkSaleRejectedNumber() {
        return linkSaleRejectedNumber;
    }

    public void setLinkSaleRejectedNumber(String linkSaleRejectedNumber) {
        this.linkSaleRejectedNumber = linkSaleRejectedNumber;
    }

    public String getLinkLogisticsNumber() {
        return linkLogisticsNumber;
    }

    public void setLinkLogisticsNumber(String linkLogisticsNumber) {
        this.linkLogisticsNumber = linkLogisticsNumber;
    }

    public List<MultipleUnit> getMultipleUnitList() {
        return multipleUnitList;
    }

    public void setMultipleUnitList(List<MultipleUnit> multipleUnitList) {
        this.multipleUnitList = multipleUnitList;
    }

    public Integer getReturnNum() {
        return returnNum;
    }

    public void setReturnNum(Integer returnNum) {
        this.returnNum = returnNum;
    }

    public Integer getIsReturn() {
        return isReturn;
    }

    public void setIsReturn(Integer isReturn) {
        this.isReturn = isReturn;
    }

    public Integer getSourceOrderId() {
        return sourceOrderId;
    }

    public void setSourceOrderId(Integer sourceOrderId) {
        this.sourceOrderId = sourceOrderId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsImage() {
        return goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage;
    }

    public String getGoodsAttribute() {
        return goodsAttribute;
    }

    public void setGoodsAttribute(String goodsAttribute) {
        this.goodsAttribute = goodsAttribute;
    }

    public String getGoodsBrand() {
        return goodsBrand;
    }

    public void setGoodsBrand(String goodsBrand) {
        this.goodsBrand = goodsBrand;
    }

    public String getBasicUnitName() {
        return basicUnitName;
    }

    public void setBasicUnitName(String basicUnitName) {
        this.basicUnitName = basicUnitName;
    }

    public String getMultipleUnitName() {
        return multipleUnitName;
    }

    public void setMultipleUnitName(String multipleUnitName) {
        this.multipleUnitName = multipleUnitName;
    }

    public String getSellwareHouseName() {
        return sellwareHouseName;
    }

    public void setSellwareHouseName(String sellwareHouseName) {
        this.sellwareHouseName = sellwareHouseName;
    }

    public Integer getBasicUnitId() {
        return basicUnitId;
    }

    public void setBasicUnitId(Integer basicUnitId) {
        this.basicUnitId = basicUnitId;
    }

    public Integer getMultipleUnitId() {
        return multipleUnitId;
    }

    public void setMultipleUnitId(Integer multipleUnitId) {
        this.multipleUnitId = multipleUnitId;
    }

    public BigDecimal getSalePriceTaxDis() {
        return salePriceTaxDis;
    }

    public void setSalePriceTaxDis(BigDecimal salePriceTaxDis) {
        this.salePriceTaxDis = salePriceTaxDis;
    }

    public Integer getUnshipped() {
        return unshipped;
    }

    public void setUnshipped(Integer unshipped) {
        this.unshipped = unshipped;
    }

    public Integer getGift() {
        return isGift;
    }

    public void setGift(Integer gift) {
        isGift = gift;
    }




    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLinkSaleNumber() {
        return linkSaleNumber;
    }

    public void setLinkSaleNumber(String linkSaleNumber) {
        this.linkSaleNumber = linkSaleNumber == null ? null : linkSaleNumber.trim();
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public Integer getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(Integer goodsNum) {
        this.goodsNum = goodsNum;
    }



    public Integer getSellwareHouse() {
        return sellwareHouse;
    }

    public void setSellwareHouse(Integer sellwareHouse) {
        this.sellwareHouse = sellwareHouse;
    }

    public Integer getBasicNum() {
        return basicNum;
    }

    public void setBasicNum(Integer basicNum) {
        this.basicNum = basicNum;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public Integer getIsGift() {
        return isGift;
    }

    public void setIsGift(Integer isGift) {
        this.isGift = isGift;
    }

    public BigDecimal getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(BigDecimal taxRate) {
        this.taxRate = taxRate;
    }

    public BigDecimal getSalePriceTax() {
        return salePriceTax;
    }

    public void setSalePriceTax(BigDecimal salePriceTax) {
        this.salePriceTax = salePriceTax;
    }

    public BigDecimal getTaxPrice() {
        return taxPrice;
    }

    public void setTaxPrice(BigDecimal taxPrice) {
        this.taxPrice = taxPrice;
    }

    public BigDecimal getGoodsDiscountRate() {
        return goodsDiscountRate;
    }

    public void setGoodsDiscountRate(BigDecimal goodsDiscountRate) {
        this.goodsDiscountRate = goodsDiscountRate;
    }

    public BigDecimal getGoodsDiscountNum() {
        return goodsDiscountNum;
    }

    public void setGoodsDiscountNum(BigDecimal goodsDiscountNum) {
        this.goodsDiscountNum = goodsDiscountNum;
    }

    public BigDecimal getGoodsSalePriceDis() {
        return goodsSalePriceDis;
    }

    public void setGoodsSalePriceDis(BigDecimal goodsSalePriceDis) {
        this.goodsSalePriceDis = goodsSalePriceDis;
    }

    public BigDecimal getGoodsTotalPriceDis() {
        return goodsTotalPriceDis;
    }

    public void setGoodsTotalPriceDis(BigDecimal goodsTotalPriceDis) {
        this.goodsTotalPriceDis = goodsTotalPriceDis;
    }

    public BigDecimal getGoodsPriceAndTax() {
        return goodsPriceAndTax;
    }

    public void setGoodsPriceAndTax(BigDecimal goodsPriceAndTax) {
        this.goodsPriceAndTax = goodsPriceAndTax;
    }

    public String getSourceOrderNum() {
        return sourceOrderNum;
    }

    public void setSourceOrderNum(String sourceOrderNum) {
        this.sourceOrderNum = sourceOrderNum == null ? null : sourceOrderNum.trim();
    }

    public BigDecimal getRefCost() {
        return refCost;
    }

    public void setRefCost(BigDecimal refCost) {
        this.refCost = refCost;
    }

    public BigDecimal getActualCost() {
        return actualCost;
    }

    public void setActualCost(BigDecimal actualCost) {
        this.actualCost = actualCost;
    }

    public BigDecimal geteGrossProfit() {
        return eGrossProfit;
    }

    public void seteGrossProfit(BigDecimal eGrossProfit) {
        this.eGrossProfit = eGrossProfit;
    }

    public BigDecimal geteGrossProfitPc() {
        return eGrossProfitPc;
    }

    public void seteGrossProfitPc(BigDecimal eGrossProfitPc) {
        this.eGrossProfitPc = eGrossProfitPc;
    }

    public BigDecimal getRecentCost() {
        return recentCost;
    }

    public void setRecentCost(BigDecimal recentCost) {
        this.recentCost = recentCost;
    }

    public String getOrigin() {
        return origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin == null ? null : origin.trim();
    }

    public String getRegisterNumber() {
        return registerNumber;
    }

    public void setRegisterNumber(String registerNumber) {
        this.registerNumber = registerNumber == null ? null : registerNumber.trim();
    }

    public String getProductionLicense() {
        return productionLicense;
    }

    public void setProductionLicense(String productionLicense) {
        this.productionLicense = productionLicense == null ? null : productionLicense.trim();
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public String getGoodsRemarks() {
        return goodsRemarks;
    }

    public void setGoodsRemarks(String goodsRemarks) {
        this.goodsRemarks = goodsRemarks == null ? null : goodsRemarks.trim();
    }
}